Global Find and Replace

The Retriever can do a lot more than "only" retrieve strings.

- You can apply second stage regular expression filters to narrow down your query to conform more closely to your needs. For information on Regular Expressions, see Reference Guide -- Regular Expressions in SNiFF+.
- You can directly edit code in the integrated Source Editor
- You can globally find and replace strings in code lines.

Setting the Project Tree
Especially for global editing you wouldn't want to include the JDK files. Also, you save time by restricting the scope of your queries.
Remember that, in the section Saving a Project Tree view, you saved a project set which we called MySources . You can now use this project set again.

- From the menu, choose View > Select Project Set > MySources

Entering a string
Earlier on you looked at Browser in various contexts, so now we will retrieve all occurrences of Browser from the source files.

In the Retrieve field (top-left edit field), enter

Browser .
Press the Retrieve button.
All occurrences of the (sub-)string Browser are displayed.
Filtering
For some reason, you might want to see all the method calls that contain the string Browser .

- To open the Find and Replace dialog, press the Filter... button.

In the Find and Replace Filter dialog

From the dialog's Regular Expressions List, select call.
Press the Apply Button.
The filter is applied as a second stage filter to the results of the original query.
Note that you can write and save your own regular expressions in this dialog.
Press Ok or Cancel to close the dialog.

The Filter field
The Filter field is used for regular expression filters. You have just filled the filter field using the Find and Replace Filter dialog. For simple filters, it is easiest to enter them directly in the field. For example, if you want to know where the string Browser is used in a comment:

In the edit field next to the Filter... button (above the Project Tree), delete the call regular expression.
Press the Retrieve button again to requery.
In the edit field next to the Filter... button, enter // and hit

<Return> .
Global Editing
Now, to change Browser to something else in all comments:

In the Change To edit field, enter, e.g.,

MyBrowser .
Take a look at the Preview field below the integrated Source Editor, the code line (highlighted in the Files -- Matches List) is shown as it would appear after modification. You can use the Next button at the bottom of the tool to look at each line as it would appear after being changed.
To change all commented occurrences of Browser to MyBrowser , press the Change All button.
In the dialog that appears, press Yes.
Remember we checked in all files in Checking in files, now we have to check out the files that we want to change - i.e., make them writable.
In the Locking Status dialog that appears, press the Select All button below the Read Only files list and press Check Out.
In the Multiple Check Out dialog that appears, press Exclusive Lock.
You'll notice that the Read Only files list in the Locking Status dialog is now empty.
In the Locking Status dialog, press OK.
All occurrences of Browser are changed to MyBrowser . You can verify this by pressing the Retrieve button again to requery.
Undoing global changes
Although the changes you made above are harmless, knowing how to undo global changes is not a bad idea. There are two possibilities to undo the changes you have just made:

- From the menu choose Edit > Undo Change All
- Use the Diff/Merge tool to track the changes and merge the differences
Although the first possibility is easier, we will choose the second possibility to undo changes and to introduce the Diff/Merge tool in the next chapter.

Review
In this chapter you:

- looked for lines in your source files containing a given set of characters
- globally edited text in the Retriever

What's next

- Close all tools except for the Launch Pad.
- In the Launch Pad, choose Tools > Project Editor.
The Project Editor appears. You will be using the Project Editor in the next part, so leave it open.